package com.itcast.googleplay.factory;

import java.util.HashMap;

import com.itcast.googleplay.fragment.AppFragment;
import com.itcast.googleplay.fragment.BaseFragment;
import com.itcast.googleplay.fragment.CategoryFragment;
import com.itcast.googleplay.fragment.GameFragment;
import com.itcast.googleplay.fragment.HomeFragment;
import com.itcast.googleplay.fragment.HotFragment;
import com.itcast.googleplay.fragment.SubjectFragment;
import com.itcast.googleplay.fragment.RecommendFragment;

public class FragmentFactory {
	public static HashMap<Integer,BaseFragment> hashMap = new HashMap<Integer,BaseFragment>();
	public static BaseFragment getFragment(int position) {
		BaseFragment baseFragment = null;
		baseFragment = hashMap.get(position);
		if(baseFragment!=null){
			return baseFragment;
		}else{
			switch (position) {
			case 0:
				baseFragment = new HomeFragment();
				break;
			case 1:
				baseFragment = new AppFragment();
				break;
			case 2:
				baseFragment = new GameFragment();
				break;
			case 3:
				baseFragment = new SubjectFragment();
				break;
			case 4:
				baseFragment = new RecommendFragment();
				break;
			case 5:
				baseFragment = new CategoryFragment();
				break;
			case 6:
				baseFragment = new HotFragment();
				break;
			}
			hashMap.put(position, baseFragment);
			return baseFragment;
		}
	}
}
